<?php

/*
 * employe/load-index.phtml
 */
?>
<?php

// Variables
$employeList	 = $this->employeList;
$nbPage		 = $this->nbPage;
$page		 = $this->page;
?>

<div class="content-body">
    <div class="list-container">
	<table class="table table-striped list-table">
	    <thead>
		<tr>
		    <td width="10%">Matricule</td>
		    <td width="15%">Poste</td>
		    <td width="10%">Contrat</td>
		    <td width="20%">Nom</td>
		    <td width="20%">Nom de Jeune Fille</td>
		    <td width="15%">Prénom</td>
		    <td width="10%">&nbsp;</td>
		</tr>
	    </thead>
	    <tbody>
		<?php foreach ($employeList as $emp): ?>
		    <?php
		    $poste	 = $emp->getPoste();
		    $avenant = $emp->getAvenant();
		    ?>
    		<tr>
		    <td style="text-align: center;"><?php echo $emp->getMatricule(true); ?></td>
    		    <td style="text-align: center;"><?php echo $poste->code; ?></td>
		    <td style="text-align: center;"><?php echo $avenant->hebdo; ?> heures</td>
		    <td style="text-align: center;"><?php echo $emp->nom1; ?></td>
    		    <td style="text-align: center;"><?php echo $emp->nom2; ?></td>
    		    <td style="text-align: center;"><?php echo $emp->prenom; ?></td>
		    <td style="text-align: center;">
    			<a href='<?php echo $this->url('RHX/default', array('controller'	 => 'employe', 'action'	 => 'edit', 'id'		 => $emp->matricule)) ?>'>
    			    <img src='<?php echo $this->basePath() . '/img/rhx/edit-16x15.png' ?>' alt='Editer' title='Editer'>
    			</a>
    			<!--&nbsp;&nbsp;&nbsp;
			<!--a class='fire-link' data-matricule='<?php echo $emp->matricule; ?>' href='<?php echo $this->url('RHX/default', array('controller'	 => 'employe', 'action'	 => 'fire', 'id'		 => $emp->matricule)) ?>'>
    			    <img src='<?php echo $this->basePath() . '/img/rhx/delete-16x16.png' ?>' alt='Effacer' title='Effacer'>
    			</a>
                        -->
    		    </td>
    		</tr>
		<?php endforeach; ?>
	    </tbody>
	    <tfoot>
		<tr>
		    <td colspan="7" style="text-align: center;">
			<?php if ($page == 1): ?>
			<?php else: ?>
			<a href="#" class="navigate-page navigate-left" data-page="1"></a>
			<?php endif; ?>
			<?php for ($i = 1; $i <= $nbPage; $i++): ?>
			    <?php if ($page == $i): ?>
				<?php echo $i; ?> &nbsp; - &nbsp;
			    <?php else: ?>
				<a href="#" class="navigate-page" data-page="<?php echo $i; ?>"><?php echo $i; ?></a> &nbsp; - &nbsp;
			    <?php endif; ?>
			<?php endfor; ?>
			<?php if ($page == $nbPage): ?>
			<?php else: ?>
				<a href="#" class="navigate-page navigate-right" data-page="<?php echo $nbPage; ?>"></a>
			<?php endif; ?>
		    </td>
		</tr>
	    </tfoot>
	</table>
    </div>
</div>

<script type="text/javascript">
    // Au chargement de la page
    $(function(){
	$('.navigate-page').click(function(e){
	    e.preventDefault();
	    page = $(this).attr('data-page');
	    $('#data-page').val(page);
	    refresh();
	});
	// Fire
	$('.fire-link').click(function(e){
	    e.preventDefault();
	    matricule = $(this).attr('data-matricule');
	    url = $(this).attr('href');
	    ajax = $.ajax({
		type: 'post',
		url : url,
		data: '&matricule=' + matricule
	    });
	    ajax.success(function(data){
		$('#dialog1').html(data).dialog({
		    title: "Suppression Employé",
		    autoOpen: true,
		    modal: true,
		    show: {effect: 'fade', duration: 1000},
		    hide: {effect: 'fade', duration: 700},
		});
	    });
	    ajax.error(function(){
		alert("Erreur");
	    });
	});
    });
</script>
